AddPrefabPostInit(
    "nightsword",
    function(inst)
        if not TheWorld.ismastersim then
            return
        end
        inst:AddComponent("npc_base_lib")
        inst:AddComponent("npc_everything_data")    
        if inst.components.named == nil then
            inst:AddComponent("named")
        end

        inst:AddComponent("rechargeable")   ------ 必须放这里，不然载入的时候在手上就不显示CD

        ------------------------------------------------------------------------------------------------
        inst:ListenForEvent("upgrade",function(inst,str)
            if str == nil then
                return
            end
            if inst.__upgraded_flag == true then
                return
            end
            inst.__upgraded_flag = true
            
            if str == "bloody" then
                TUNING.NPC_UPGRADE_ITEMS_FN["nightsword"]():upgrade_bloody(inst)
                inst.components.npc_everything_data:Set("upgrade","bloody")
            end
            
        end)

        inst:DoTaskInTime(0,function()
            local the_type =  inst.components.npc_everything_data:Get("upgrade")
            if the_type ~= nil then
                inst:PushEvent("upgrade",the_type)                
            end
        end)
        ------------------------------------------------------------------------------------------------
    end
)